package com.dkh.recommend.controller;


import com.dkh.recommend.dto.Result;
import com.dkh.recommend.entity.TbComment;
import org.springframework.stereotype.Controller;
import com.dkh.recommend.service.ITbCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dkh
 * @since 2022-12-14
 */
@Slf4j
@RestController
@Api(value = "评论", tags = "评论-相关", description="评论-相关")
@RequestMapping("/comment")
public class TbCommentController {

    @Autowired
    private ITbCommentService commentService;

//    评论2音乐
    @PostMapping("/add")
    public Result addComment(@RequestBody TbComment comment){
        return commentService.addComment(comment);
    }

//    查看我的评论
    @GetMapping("/myComment")
    public Result myComment(){
        return commentService.myComment();
    }

//    删除评论
    @DeleteMapping("/delete/{commentId}")
    public Result deleteComment(@PathVariable("commentId") Long commentId){
    return commentService.deleteComment(commentId);
    }

//    根据音乐id获得音乐的评论
    @GetMapping("/bymusicid/{musicId}")
    public Result getCommentByMusicId(@PathVariable("musicId") String musicId){
        return commentService.getCommentByMusicId(musicId);
    }

//    点赞/取消点赞
    @PutMapping("/like/{commentId}")
    public Result likeComment(@PathVariable("commentId") String commentId){
        return commentService.likeComment(commentId);
    }

//   是否点赞
    @GetMapping("/or/not/like/{commentId}")
    public Result orNotLike(@PathVariable("commentId") String commentId){
        return commentService.orNotLike(commentId);
    }





}
